dojo.declare("MRegistrationPg", wm.Page, {
    start: function() {

    },
    "preferredDevice": "phone",

    svLoginSuccess: function(inSender, inDeprecated) {



    },
    svLoginResult: function(inSender, inDeprecated) {
        try {
            var result = inSender.getItem(0);

            if (result.data.authenticated === true || result.data.authenticated === 'true') {
                this.notifyLogin.update();

                var mainPage = wm.Page.getPage("MobileMainPg");


                mainPage.vUserName = result.data.name;
                mainPage.vUserEmail = result.data.email;
                mainPage.vUserId = result.data.customerId;
                mainPage.vProjectId = result.data.projectId;

                mainPage.headerPanel.setShowing(false);
                if (result.data.roles === 'CUSTOMER') {
                    mainPage.ncCustomerService.update();
                } else if (result.data.roles === 'VENDOR') {
                    mainPage.ncVendorHomePg.update();
                } else if (result.data.roles === 'ADMIN') {
                    mainPage.ncCustomerService.update();
                }



            } else {
                this.notifyLoginError.update();
                this.loginErrorMsg.setCaption("Invalid username or password.");
                this.usernameInput.focus();

            }

        } catch (e) {

            this.label1.caption = e;

        }




    },
    buttonRegistrationClick: function(inSender) {
        var isValid = true;
        if (!this.textActivationCode.getDataValue() || (this.textActivationCode && this.textActivationCode.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.emailEditor1.getDataValue() || (this.emailEditor1 && this.emailEditor1.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.passwordEditor1.getDataValue() || (this.passwordEditor1 && this.passwordEditor1.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.nameEditor1.getDataValue() || (this.nameEditor1 && this.nameEditor1.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.lookupBlocks.getDataValue() || (this.lookupBlocks && this.lookupBlocks.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.lookupDoor.getDataValue() || (this.lookupDoor && this.lookupDoor.getDataValue() === "")) {
            isValid = false;
        }
        if (!this.primaryPhoneEditor1.getDataValue() || (this.primaryPhoneEditor1 && this.primaryPhoneEditor1.getDataValue() === "")) {
            isValid = false;
        }
        if (isValid) {
            this.svRegistration.update();
        } else {
            this.ncRequiredFields.update();

        }
    },
    picture1Click: function(inSender) {
        this.picture2.setShowing(true);
        this.picture1.setShowing(false);
    },
    picture2Click: function(inSender) {
        this.picture2.setShowing(false);
        this.picture1.setShowing(true);

    },
    _end: 0
});